﻿using System;
using System.Threading.Tasks;
using WorkFlow.Data;

namespace WorkFlow.Pages
{
    public partial class Index
    {
        private string _workFlowName;
        private string _User;
        private int _Status = -1;
        private string _Message;
        private DateTime _StartTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:01"));
        private DateTime _EndTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
        protected override Task OnInitializedAsync()
        {
            commentTool.ShowNav = true;
            return base.OnInitializedAsync();
        }
        protected override void OnAfterRender(bool firstRender)
        {
            base.OnAfterRender(firstRender);
            if (firstRender)
            {
                Search();
            }
        }
        private void Search()
        {
            workFlowInfoList = dataManager.GetWorkFlowInfo(_workFlowName, _User, _Status, _Message, _StartTime.ToString("yyyy-MM-dd 00:00:01"), _EndTime.ToString("yyyy-MM-dd 23:59:59"));
            UpdateUI();
        }
        private void SearchParaters(string mainID)
        {
            parameterEntityList = dataManager.GetAllParameterEntityByMainID(mainID);
            UpdateUI();
        }
        private void HiddenNav()
        {
            commentTool.ShowNav = false;
        }
        private async void UpdateUI()
        {
            await InvokeAsync(() => StateHasChanged());
        }
    }
}
